package com.mcptt.config.body.info.mcdata;

import java.io.UnsupportedEncodingException;

public class InfoBodyPublishMcdata {

	private String mcdataId = "";
	private String accessToken = null;
	private String clientId = "";
	
	public InfoBodyPublishMcdata(String mcdataId, String accessToken, String clientId)
	{
		this.mcdataId = mcdataId;
		this.accessToken = accessToken;
		this.clientId = clientId;
	}
	
	public InfoBodyPublishMcdata(String mcdataId, String clientId)
	{
		this.mcdataId = mcdataId;
//		this.accessToken = accessToken;
		this.clientId = clientId;
	}
	
	public String toString()
	{
		StringBuffer strBuff = new StringBuffer();
		strBuff.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\r\n");
		strBuff.append("<mcdatainfo xmlns:mgktp=\"urn:3gpp:ns:mcpttGKTP:1.0\" xmlns=\"urn:3gpp:ns:mcdataInfo:1.0\">").append("\r\n");
		strBuff.append("<mcdata-Params>").append("\r\n");
		strBuff.append("<mcdata-request-uri type=\"Normal\">").append("\r\n");
		strBuff.append("<mcdataURI>").append(mcdataId).append("</mcdataURI>").append("\r\n");
		strBuff.append("</mcdata-request-uri>").append("\r\n");
		strBuff.append("<mcdata-access-token type=\"Normal\">").append("\r\n");
		if(accessToken != null)
		{
			strBuff.append("<mcdataString>").append(accessToken).append("</mcdataString>").append("\r\n");
		}
		else
		{
			strBuff.append("<mcdataString>").append(mcdataId).append("</mcdataString>").append("\r\n");
		}
		
		strBuff.append("</mcdata-access-token>").append("\r\n");
		strBuff.append("<mc-org>CRSC_MCX_GPH</mc-org>").append("\r\n");
		strBuff.append("<mcdata-client-id type=\"Normal\">").append("\r\n");
		strBuff.append("<mcdataString>").append(clientId).append("</mcdataString>").append("\r\n");
		strBuff.append("</mcdata-client-id>").append("\r\n");
		strBuff.append("</mcdata-Params>").append("\r\n");
		strBuff.append("</mcdatainfo>");
		
		try {
			return new String(strBuff.toString().getBytes(),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return strBuff.toString();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
